# -*- coding: utf8 -*-
#
# Copyright (c) 2009 Matías Ribecky <status-notifications@mribecky.com.ar>
#
# This file is part of status-notifications.
# 
# status-notifications is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# status-notifications is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with status-notifications.  If not, see <http://www.gnu.org/licenses/>.

import datetime

import statusnotifications.cache

class User(object):
    '''A user.

    .. attribute:: name
        :type: unicode

        The user real name.

    .. attribute:: user_name
        :type: unicode

        The user's screen name.

    .. attribute:: creation_date
        :type: datetime.datetime

        The moment the user was created.

    .. attribute:: image_url
        :type: unicode

        The url of the profile image.

    .. attribute:: image
        :type: unicode

        The local path to the cached profile image.

    .. attribute:: description
        :type: unicode

        The user's description.

    .. attribute:: url
        :type: unicode

        The user's profile url.

    '''
    def __init__(self, user_data):
        self.name = user_data['name']
        self.user_name = user_data['screen_name']
        self.creation_date = user_data['created_at']
        self.image_url = user_data['profile_image_url']
        self.image = statusnotifications.cache.get_user_image(self.user_name,
                                                              self.image_url)
        self.description = user_data['description']
        self.url = user_data['url']

class Status(object):
    '''A status.

    .. attribute:: id
        :type: int

        The status' id.

    .. attribute:: date
        :type: datetime.datetime

        The moment when the status was published.

    .. attribute:: user
        :type: User

        The poster of the status.

    .. attribute:: message
        :type: unicode

        The content of the status.

    .. attribute:: service_name
        :type: unicode

        The name of the service from where the status is.

    '''

    def __init__(self, status_data):
        self.id = status_data['id']
        self.date = status_data['created_at']
        self.message = status_data['text']
        self.user = User(status_data['user'])
        self.service_name = status_data['service_name']
